using System;

namespace Test.ConsoleProgram.Algorithm.Solution
{
    [TestDescription("算法: 1014. 最佳观光组合")]
    public class No1014_MaxScoreSightseeingPair : AbsBaseTestItem
    {
        public override void OnTest()
        {
            Assert.TestExe(MaxScoreSightseeingPair, new int[] { 8, 1, 5, 2, 6 }, 11);
        }

        public int MaxScoreSightseeingPair(int[] A)
        {
            int result = 0, mx = 0;
            for (int j = 0; j < A.Length; j++)
            {
                result = Math.Max(result, mx + A[j] - j);
                int i = j;
                mx = Math.Max(mx, A[i] + i);
            }
            return result;
        }
    }
}
